<template>
  <div class="dashboard-editor-container">
    <panel-group @handleSetLineChartData="handleSetLineChartData" />

    <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <line-chart :chart-data="lineChartData" />
    </el-row>

    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8" style="width:50%;">
        <div class="chart-wrapper">
          <span>金额比例</span>
          <pie-chart />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8" style="width:50%;">
        <div class="chart-wrapper">
          <span>服务和配送订单</span>
          <bar-chart />
        </div>
      </el-col>
      <div class="table" style="width:98%;margin-left:16px;floa:left">
        <h3>服务订单</h3>
        <el-table :data="tableData">
          <el-table-column label="订单号" prop="num" align="center" />
          <el-table-column label="金额" prop="money" align="center" />
          <el-table-column prop="time" align="center" label="下单时间" />
          <el-table-column prop="user" align="center" label="下单用户" />
          <el-table-column prop="phone" align="center" label="联系方式" />
          <el-table-column prop="area" align="center" width="250" label="上门地址" />
          <el-table-column align="center" label="订单状态" prop="state" />
        </el-table>
      </div>
    </el-row>
  </div>
</template>

<script>
import LineChart from './components/LineChart'
import PieChart from './components/PieChart'
import BarChart from './components/BarChart'
import PanelGroup from './components/PanelGroup'

const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 90, 100, 154, 162, 140, 145]
  }
}

export default {
  name: 'DashboardAdmin',
  components: {
    LineChart,
    PieChart,
    BarChart,
    PanelGroup
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis,
      tableData: [
        {
          num: '4865215355456212321',
          money: '￥20',
          state: '配送中',
          time: '2019-12-01 19:34',
          phone: '13199451349',
          area: '浙江省杭州市下城区下沙大都会风情苑8幢6单元902室',
          user: '赵先生'
        },
        {
          num: '8785212123123123123',
          money: '￥18',
          state: '待接单',
          user: '黄女士',
          area: '浙江省杭州市下城区下沙大都会风情苑8幢4单元502室',
          time: '2019-12-01 19:34',
          phone: '13199451349'
        },
        {
          num: '8978212312121231232',
          time: '2019-12-01 19:34',
          money: '￥20',
          state: '配送中',
          user: '刘女士',
          phone: '13199451349',
          area: '浙江省杭州市下城区下沙大都会风情苑11幢1单元101室'
        },
        {
          num: '4865215355456212321',
          time: '2019-12-01 19:34',
          area: '浙江省杭州市下城区下沙大都会风情苑7幢9单元702室',
          user: '刘女士',
          phone: '13199451349',
          money: '￥20',
          state: '配送中'
        },
        {
          num: '7841235645231365112',
          user: '赵先生',
          time: '2019-12-01 19:34',
          area: '浙江省杭州市下城区下沙大都会风情苑8幢6单元902室',
          phone: '13199451349',
          money: '￥15',
          state: '待接单'
        }
      ]
    }
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width: 1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
